package core

import (
	"blog_go/global"
	"github.com/go-redis/redis"
	"github.com/sirupsen/logrus"
)

func InitRedis() {
	client := redis.NewClient(&redis.Options{
		Addr:     global.Conf.Redis.Addr(),
		Password: global.Conf.Redis.Password,
		DB:       global.Conf.Redis.DB,
		PoolSize: global.Conf.Redis.PoolSize,
	})
	_, err := client.Ping().Result()
	if err != nil {
		logrus.Errorf("Redis连接失败,%s", err)
		panic(err)
	}
	global.Redis = client
}
